package com.example.sharedpreference;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class HomeActivity extends Activity {
	private Button resetButton;
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		Log.i("HomeActivity", "onCreate");
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_home);
	    
		resetButton = (Button) findViewById(R.id.resetButton);
		
		resetButton.setOnClickListener( new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				SharedPreferences prefs = getSharedPreferences(
						"LoginPref", MODE_PRIVATE);

				SharedPreferences.Editor ed = prefs.edit();
				ed.putBoolean("auto_login", false);
				ed.commit();

				Intent intent = new Intent(HomeActivity.this,
						MainActivity.class);
				startActivity(intent);
				finish();

			}
		}); //setOnClickLisneter
	}
}
